﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhSystemBLL.orderData;
using dhSystemBLL.produceBLL;
using baseSet.importExport;
using dhsystem.Main;
using dhDataAcess.baseBLL;
using FastReport;

namespace dhsystem.produceForm.Stock
{
    public partial class FrmV_packDetail : Form
    {
        public FrmV_packDetail()
        {
            InitializeComponent();
        }

        private void FrmV_packDetail_Load(object sender, EventArgs e)
        {
            packStockInBLL packStockIn = new packStockInBLL();
            //orderProduceListBLL orderProduceLsit = new orderProduceListBLL();
            //string orderNo = dGridorder.CurrentRow.Cells["orderNo"].Value.ToString();
            bindingSourceorder.DataSource = packStockIn.getV_packbiaoqianAll();
            dGridpack.DataSource = bindingSourceorder;
            DcolumnSet.colSet(moduleInfo.V_packbiaoqian, dGridpack);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridpack.RowCount.ToString() + "条";
        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {

            try
            {
                baseSet.Query q = new baseSet.Query(null, dhDataAcess.baseBLL.dataConn.connOpen());
                bindingSourceorder.DataSource = q.sqlQueryLikeAll(moduleInfo.V_packbiaoqian, textMatNameQuery.Text.ToString().Trim());
                dGridpack.DataSource = bindingSourceorder;
                DcolumnSet.colSet(moduleInfo.V_packbiaoqian, dGridpack);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void buttupdate_Click(object sender, EventArgs e)
        {
            packStockInBLL packStockIn = new packStockInBLL();
            //orderProduceListBLL orderProduceLsit = new orderProduceListBLL();
            //string orderNo = dGridorder.CurrentRow.Cells["orderNo"].Value.ToString();
            bindingSourceorder.DataSource = packStockIn.getV_packbiaoqianAll();
            dGridpack.DataSource = bindingSourceorder;
            DcolumnSet.colSet(moduleInfo.V_packbiaoqian, dGridpack);
            toolStripStatusLabel1.Text = "数据总条数:" + dGridpack.RowCount.ToString() + "条";
        }

        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolExport_Click(object sender, EventArgs e)
        {
            FrmExcelExport frm = new FrmExcelExport(moduleInfo.V_packbiaoqian, dGridpack, "包装明细");
            frm.ShowDialog();
        }

        private void toolQuery_Click(object sender, EventArgs e)
        {
            FrmDataQuery query = new FrmDataQuery(moduleInfo.V_packbiaoqian);
            DialogResult result = query.ShowDialog();
            if (result == DialogResult.Yes)
            {
                dGridpack.DataSource = query.rTable;
            }
        }

        private void 普通标签ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<string> list = new List<string>();
            foreach (DataGridViewRow row in dGridpack.SelectedRows)
            {
                list.Add(row.Cells["boxno"].Value.ToString());
            }
            basicSql.getproduceNo((list), dGridpack.CurrentRow.Cells["orderDetailNo"].Value.ToString());
            Report r = new Report();
            DataTable V_orderproduceTable = new DataTable();
            V_orderproduceTable.Load(basicSql.getproduceNo((list), dGridpack.CurrentRow.Cells["orderDetailNo"].Value.ToString()));
            DataSet ds = new DataSet();
            ds.Tables.Add(V_orderproduceTable);
            //  ds.Tables.Add(orderProduceList.getproduceByproduceNo(dGridorderProduceList.CurrentRow.Cells["produceNo"].Value.ToString()));
            //  r.Load(@"e:\东华软件项目\报表\orderproduce.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\packbiaoqian.frx");

            r.RegisterData(ds);
            //r.Design();
            r.Show();
        }

        private void 河源标签ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<string> list = new List<string>();
            foreach (DataGridViewRow row in dGridpack.SelectedRows)
            {
                list.Add(row.Cells["boxno"].Value.ToString());
            }
            basicSql.getproduceNo((list), dGridpack.CurrentRow.Cells["orderDetailNo"].Value.ToString());
            Report r = new Report();
            DataTable V_orderproduceTable = new DataTable();
            V_orderproduceTable.Load(basicSql.getproduceNo((list), dGridpack.CurrentRow.Cells["orderDetailNo"].Value.ToString()));
            DataSet ds = new DataSet();
            ds.Tables.Add(V_orderproduceTable);
            //  ds.Tables.Add(orderProduceList.getproduceByproduceNo(dGridorderProduceList.CurrentRow.Cells["produceNo"].Value.ToString()));
            //  r.Load(@"e:\东华软件项目\报表\orderproduce.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\packbiaoqianheyuan.frx");

            r.RegisterData(ds);
            //r.Design();
            r.Show();
        }
    }
}
